package searcher;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Version;

import util.Configuration;

public class LuceneQueryParser {
	public static Query parse(String term) {

		Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
		QueryParser queryParser = new MultiFieldQueryParser(Version.LUCENE_35,
				Configuration.LUCENE_INDEX_DOC_FIELDS, analyzer,
				Configuration.LUCENE_INDEX_DOC_FIELDS_BOOST);
		Query query = null;

		try {
			query = queryParser.parse(term);
		} catch (ParseException e) {
			e.printStackTrace();
		}

		return query;
	}
}
